package com.shop.user.service;



import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.shop.common.pojo.SpManager;
import com.shop.user.mapper.UserMapper;
import org.apache.catalina.Manager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl {
    @Autowired
    private UserMapper userMapper;

    public SpManager findById(Integer productId) {
        return userMapper.selectById(productId);
    }
    public List<SpManager> findAll() {
        return userMapper.selectList(null);
    }
    public List<SpManager> findAndLimit(String query,int pagenum,int pagesize) {
        List<SpManager> list= userMapper.findAndLimit(query,(pagenum-1)*pagesize,pagesize);
        return list;
    }
    public int findNoLimit(String query) {
        int list= userMapper.findNoLimit(query).size();
        return list;
    }

    public int updateUser(SpManager spManager) {
        UpdateWrapper<SpManager> wrapper=new UpdateWrapper<>();
        wrapper.set("mg_state",spManager.getMgState());
        return userMapper.update(spManager,wrapper);
    }
}
